<div id ="compare">Course Comparison between <?php echo $this->name1[0]->course_no ." (" .$this->date1 .")";?> and 
<?php echo $this->name2[0]->course_no ." (" .$this->date2 .")"; ?> </div> 
<br></br>
<div id ="ratings">Course Data</div>
  <div id="holder">
        </div>
<?php 
$this->dojo()->enable();
//print_r($this->data);
//print_r($this->data2);
//echo $this->data->toArray();

//print_r($data->final);
foreach($this->paginator as $list) {

	$grade = null;
	
if ($list['final'] == 1){
	$grade = "A/A-";
}
else if($list['final'] == 2){
	$grade = "B+/B";
}
else if ($list['final'] == 3){
	 $grade = "B-/C";
}
else if ($list['final'] == 4){
	$grade  = "C-/D";
}
else if ($list['final'] == 5) {
	$grade = "F";
}
else{
	$grade = "";
}

$diff = $list['diff'];
$time = $list['time'];
$text = $list['use_rating'];
$ins = $list['i_rating'];
$dat1 = "Number of respondents :" .$list['recount'] ."<br>"
 		."Grade :" .$grade . "<br>"
 		."Difficulty: " .$diff . "<br>"
 		."Time : "  .$time . "<br>"
 		."Usefulness of textbook:  ".$text . "<br>"
 		."Instructor rating:  ".$ins . "<br>"
 		."Bar-Color: Black";
}
$ratecount1 = $list['recount'];
$course1 =  $this->name1[0]->course_no ." (" .$this->date1 .")"; 
$course2 =  $this->name2[0]->course_no ." (" .$this->date2 .")"; 
?>
<?php 
foreach($this->paginator2 as $list) {

	$grade2 = null;
	
if ($list['final'] == 1){
	$grade2 = "A/A-";
}
else if($list['final'] == 2){
	$grade2 = "B+/B";
}
else if ($list['final'] == 3){
	 $grade2 = "B-/C";
}
else if ($list['final'] == 4){
	$grade2  = "C-/D";
}
else if ($list['final'] == 5) {
	$grade2 = "F";
}
else{
	$grade2 = "";
}

$diff2 = $list['diff'];
$time2 = $list['time'];
$text2 = $list['use_rating'];
$ins2 = $list['i_rating'];
$dat2= "Number of respondents :" .$list['recount'] ."<br>"
 ."Grade :" .$grade2 . "<br>"
 ."Difficulty: " .$diff2 . "<br>"
 ."Time : "  .$time2 . "<br>"
 ."Usefulness of textbook:  ".$text2 . "<br>"
."Instructor rating:  ".$ins2 . "<br>"
. "Bar Color: Light-Blue";
}
$ratecount2 = $list['recount'];
$msg = null;
if (($ratecount1 == 0)||( $ratecount2 == 0)){
	
	$msg = "No data exists for either one of the courses you have chosen so no comparison plot can be generated";
}else{
	$msg = "Plot of Average ratings";
}
$legend= "<strong>Course Indicators</strong><br>"
		."$course1--Bar Color : Black <br>$course2--Bar Color : Light Blue" 
	 ."<br><strong>Descripion of rating parameters</strong>"
	."<br>Difficulty:" ."1-- Very Easy, 2-- Easy, 3 -- Moderate, 4--Difficult, 5-- Very Difficult<br>"
 ."Time :" ."1-- Very Light, 2-- Light, 3-- Average, 4-- Heavy 5-- Very Heavy<br>"
 ."Instructor :" ."1-- Very Poor, 2-- Poor, 3-- Average, 4-- Good, 5-- Excellent<br>"
 ."Usefulness of textbook:"  ."1-- Very Poor, 2-- Poor, 3-- Moderate, 4-- Useful, 5-- Very Useful";
?>
<p></p>
<h3><?php echo $msg; ?></h3>

<script type="text/javascript">
dojo.require("dijit.TitlePane");

dojo.require("dojox.charting.Chart2D");

makeCharts = function(){

	var chart1 = new dojox.charting.Chart2D("simplechart");
	chart1.addPlot("default", {type: "ClusteredColumns", lines: true, areas: true,
        markers: false, gap:"12"});
	 chart1.addAxis("x", {
         labels: [{value: 1, text: "Difficulty" }, {value: 2, text: "Time Burden"},
                 {value: 3, text: "Usefulness Textbook"}, {value: 4, text: "Instructor Rating"}]
         }); 
                    chart1.addAxis("y", {vertical: true, min: 0, max: 5,  stroke: "black"});
	chart1.addSeries("Series 1", [<?php echo $diff;?>, <?php echo $time; ?>, <?php echo $text?>, <?php echo $ins?>]);
	chart1.addSeries("Series 2", [<?php echo $diff2;?>, <?php echo $time2; ?>, <?php echo $text2?>, <?php echo $ins2?>],
{plot: "default", stroke: {color:"blue"}, fill: "lightblue"});
chart1.render();

	 
};

add = function() {
    tp = new dijit.TitlePane({
        title: "<?php echo $course1; ?>",
        content: "<?php echo $dat1;?>",
        style: "width:300px",
        open: false
    });

    com = new dijit.TitlePane({
        title: "<?php echo $course2;?>",
        content: "<?php echo $dat2; ?>", 
        style: "width:300px",  
        open: false
    });

    legend = new dijit.TitlePane({
        title: "Comparison Legend",
        content: "<?php echo $legend; ?>", 
        open: false
    });

    dojo.byId("holder").appendChild(tp.domNode);
    dojo.byId("holder").appendChild(com.domNode);
    dojo.byId("legend").appendChild(legend.domNode);
    
    
    
};
dojo.addOnLoad(add);
dojo.addOnLoad(makeCharts);
</script>
<div id="simplechart" align = "left" style="width: 600px; height: 200px;"></div>

<div id="legend">
</div>